package com.xxzb.pack0720;

import java.lang.ref.PhantomReference;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Scanner;

public class Test6 {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入您要查询的图书名称：");
        String bookname=sc.next();
        Class.forName("com.mysql.jdbc.Driver");
        String url = "jdbc:mysql:///gaofeng2207?useSSL=false";
        String username="root";
        String password="1234";
        Connection conn= DriverManager.getConnection(url,username,password);
        String sql="select incount from gaofeng2207.stock s,gaofeng2207.books b where s.bookid=b.bookid and bookname=?";
        PreparedStatement ps=conn.prepareStatement(sql);
        ps.setString(1,bookname);
        ResultSet rs = ps.executeQuery();
        while (rs.next()){
            int incount = rs.getInt("incount");
            System.out.println("incount="+incount);
        }

    }
}
